﻿using AutoMapper;
using Enferno.Public.Web.Models;
using Enferno.Public.Web.ShoppingBasket.ViewModels;

namespace Enferno.Public.Web.ShoppingBasket.Mappers
{
    public class BasketItemModelToBasketItemViewModelProfile: Profile
    {
        protected override void Configure()
        {
            Mapper.CreateMap<BasketItemModel, BasketItemViewModel>()
                .ForMember(to => to.DisplayPrice, opts => opts.MapFrom(from => from.Price.Display))
                .ForMember(to => to.OriginalPrice, opts => opts.MapFrom(from => from.Price.Original))
                .ForMember(to => to.IsDiscountable, opts => opts.MapFrom(from => from.IsDiscountable))
                .ForMember(to => to.IsEditable, opts => opts.MapFrom(from => from.IsEditable))
                .ForMember(to => to.Type, opts => opts.MapFrom(from => from.Type))
                .ForMember(to => to.UnitOfMeasurement, opts => opts.MapFrom(from => from.UnitOfMeasurement))
                .ForMember(to => to.VatRate, opts => opts.MapFrom(from => from.Price.VatRate));
        }

        public override string ProfileName
        {
            get { return GetType().Name; }
        }
    }
}
